DepUsersForm = Ext
		.extend(
				Ext.Window,
				{
					constructor : function(a) {
						Ext.applyIf(this, a);
						this.initUIComponents();
						DepUsersForm.superclass.constructor.call(this, {
							id : "DepUsersFormWin",
							iconCls : "menu-department",
							layout : "fit",
							items : this.formPanel,
							modal : true,
							height : 180,
							minHeight : 180,
							width : 500,
							minWidth : 500,
							maximizable : true,
							title : this.depName == null ? "新增/编辑部门员工信息"
									: "新增/编辑部门[" + this.depName + "]员工信息",
							buttonAlign : "center",
							buttons : [ {
								text : "保存",
								iconCls : "btn-save",
								scope : this,
								handler : this.save
							}, {
								text : "取消",
								iconCls : "btn-cancel",
								scope : this,
								handler : this.cancel
							} ],
							keys : {
								key : Ext.EventObject.ENTER,
								fn : this.save,
								scope : this
							}
						});
					},
					initUIComponents : function() {
						this.formPanel = new Ext.FormPanel(
								{
									id : "DepUsersForm",
									layout : "form",
									bodyStyle : "padding:10px",
									border : false,
									autoScroll : true,
									defaults : {
										anchor : "96%,96%"
									},
									defaultType : "textfield",
									items : [
											{
												name : "depUsers.depUserId",
												xtype : "hidden",
												value : this.depUserId == null ? ""
														: this.depUserId
											},
											{
												name : "depUsers.staff.id",
												xtype : "hidden"
											},
											{
												xtype : "container",
												layout : "column",
												fieldLabel : "员工名称",
												style : "margin-bottom:4px;",
												defaultType : "label",
												items : [
														{
															columnWidth : 0.99,
															xtype : "textfield",
															name : "depUsers.staff.name",
															readOnly : true,
															allowBlank : false,
															maxLength : 128
														},
														{
															xtype : "button",
															iconCls : "btn-user-sel",
															text : "请选择",
															scope : this,
															handler : function() {
																UserSelector
																		.getView({
																			callback : function(records) {
																				var b = Ext.getCmp("DepUsersForm");
																				b.getCmpByName("depUsers.staff.id")
																						.setValue(records[0].data.id);
																				b.getCmpByName("depUsers.staff.name").setValue(
																						records[0].data.name);
																			},
																			url :__ctxPath + "/system/listStaff.do?depId="+this.depId
																		})
																		.show();
															},
															disabled : this.depUserId == null ? false
																	: true
														} ]
											},
											{
												name : "depUsers.department.depId",
												xtype : "hidden",
												value : this.depId == null ? ""
														: this.depId
											},
											{
												fieldLabel : "主部门(是/否)",
												hiddenName : "depUsers.isMain",
												xtype : "combo",
												triggerAction : "all",
												editable : false,
												mode : "local",
												store : [ [ "0", "否" ],
														[ "1", "是" ] ],
												value : 0,
												allowBlank : false,
//												anchor : "99%"
											}, {
												name : "depUsers.sn",
												xtype : "hidden"
											} ]
								});
						if (this.depUserId != null
								&& this.depUserId != "undefined") {
							this.formPanel.loadData({
								url : __ctxPath
										+ "/system/getDepUsers.do?depUser.depUserId="
										+ this.depUserId,
								root : "result",
								preName : "depUsers"
							});
						}
					},
					cancel : function() {
						this.close();
					},
					save : function() {
						var a = Ext.getCmp("DepUsersForm");
						if (a.getForm().isValid()) {
							a
									.getForm()
									.submit(
											{
												url : __ctxPath
														+ "/system/saveDepUsers.do",
												waitMsg : "数据正在提交，请稍后...",
												method : "post",
												success : function() {
													Ext.getCmp("DepUsersView")
															.getStore()
															.reload();
													Ext.ux.Toast.msg("操作提示",
															"数据操作成功！");
													Ext.getCmp(
															"DepUsersFormWin")
															.close();
												},
												failure : function(b, d) {
													var c = Ext.util.JSON
															.decode(d.response.responseText);
													Ext.ux.Toast.msg("操作提示",
															c.msg);
												}
											});
						}
					}
				});